/**
 * #info
 *
 *@author   wuwg
 *@createTime   2018/03/20
 *@updateTime   2018/06/02
 *@description  time-picker  component   时间控件
 */

/**
 * #item
 *
 * @type            aty-time-picker
 * @cn              时间选择器
 * @menu            表单
 * @stPlugin        true
 * @stContainer     false
 * @mixins        [
 * ./components/components/form/date-picker/picker.js,
 * ./components/components/form/date-picker/base/time-spinner.js,
 * ./components/components/form/date-picker/base/confirm.js,
 * ./components/components/form/date-picker/time-mixins.js,
 * ./components/mixins/form-item-props.js
 * ]
 * @order 1001
 * @description
 * time-picker  入口文件
 * picker.js    主文件
 * time-spinner.js    time-spinner.vue 组件
 * confirm.js    confirm.vue 组件
 * time-mixins.js    time混入的js
 */

// components
import Picker from '../date-picker/picker.vue'
import TimePickerPanel from '../date-picker/panel/time/time.vue'
import RangeTimePickerPanel from '../date-picker/panel/time/time-range.vue'
import Options from '../date-picker/time-mixins.js'
// module
export default {
  name: 'aty-time-picker',
  mixins: [Picker, Options],
  components: { TimePickerPanel, RangeTimePickerPanel },
  props: {
    /**
     * #property
     *
     * @name            type
     * @cn              时间选择器
     * @group           基本属性
     * @type            list
     * @options         [time, timerange]
     * @value           time
     * @description     该项取值为 ['time', 'timerange']中的其中一个
     */
    type: {
      /*
       *       validator (value) {
       * console.log(value)
       * return   true //Artery.isOneOf(value, ['time', 'timerange']);
       *},
       */
      type: String,
      default: 'time'
    },
    /**
     * #property
     *
     * @name    value
     * @cn      值
     * @group   基本属性
     * @type    string,array,object
     * @description 时间，可以是 JavaScript 的 Date，例如 new Date()，也可以是标准的时间格式
     * 注意：value 使用 .sync 时，返回的是 Date 类型，需配合 @on-change 使用
     */
    value: {
      type: [Date, String, Array]
    }
  },
  computed: {
    panel () {
      const isRange = this.type === 'timerange'
      return isRange ? 'RangeTimePickerPanel' : 'TimePickerPanel'
    },
    ownPickerProps () {
      return {
        disabledHours: this.disabledHours,
        disabledMinutes: this.disabledMinutes,
        disabledSeconds: this.disabledSeconds,
        hideDisabledOptions: this.hideDisabledOptions
      }
    }
  }
}
